<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
    <script>
      // 1.基本使用
      axios
        .all([axios.get("url"), axios.get("url2", { params: { id: 1 } })])
        .then((res) => {
          //请求返回的是数组
          console.log(res[0]);
          console.log(res[1]);
        })
        .catch((err) => {
          console.log(err[0]);
        });
      // 2.使用 axios.spread处理结果
      axios
        .all([
          axios.get("ur3"),
          axios.get("ur4", { params: { id: 1 } }),
          axios({
            url: "ff",
            params: {
              id: 1,
            },
          }),
        ])
        .then(
          axios.spread((res1, res2) => {
            console.log(res1);
            console.log(res2);
          })
        )
        .catch((err) => {
          console.log(err[0]);
        });
    </script>
  </body>
</html>
